<template>
  <!-- 档案换盒记录 -->
  <div>
    <el-card class="box-card" :body-style="{ padding: 10 }">
      <el-form :inline="true" :model="queryParam" class="demo-form-inline" size="medium">
        <el-form-item label="档号/题名">
          <el-input v-model="queryParam.archiveNoOrName" placeholder="请输入档号或题名" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询</el-button>
          <el-button @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <el-card class="box-card" :body-style="{ padding: 10 }">
      <el-table :data="tableData" border style="width: 100%" height="55vh">
        <el-table-column type="index" label="序号" align="center" width="50"> </el-table-column>
        <el-table-column v-for="item of tableProps" :key="item.props" :prop="item.prop" :label="item.title"
          :width="item.width">
        </el-table-column>
        <!--        <el-table-column label="操作" min-width="100">-->
        <!--          <template slot-scope="{row}">-->
        <!--            <el-button icon="el-icon-view" link size="mini"-->
        <!--                       @click="handleShow(row)">查看</el-button>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
      </el-table>
    </el-card>
    <el-card class="box-card" :body-style="{ padding: 10 }">
      <pagination ref="pagination" :totalCount="totalCount" @pagination="pagination"></pagination>
    </el-card>
  </div>
</template>

<script>
import { pageList } from '@/api/rfid/boxReplace'
export default {
  name: 'boxReplaceRecord',
  data() {
    return {
      totalCount: 0, //总数
      //查询条件
      searchModel: {
        pageNo: 1,
        pageSize: 10,
      },
      queryParam: {},
      tableData: [],
      tableProps: [
        { title: '档号', prop: 'archiveNo', width: '', checked: true },
        { title: '原盒号', prop: 'oldBoxNo', width: '', checked: true },
        { title: '盒号', prop: 'newBoxNo', width: '', checked: true },
        { title: '题名', prop: 'archiveName', width: '', checked: true },
        { title: '操作时间', prop: 'createTime', width: '', checked: true },
        { title: '操作人', prop: 'createByName', width: '', checked: true },
      ],
    }
  },

  mounted() {
    this.loadData()
  },

  methods: {
    onSubmit() {
      this.$refs.pagination.resetPagination()
    },
    onReset() {
      this.queryParam = {}
      this.$refs.pagination.resetPagination()
    },
    loadData() {
      var param = Object.assign(this.queryParam, this.searchModel)
      pageList(param)
        .then((res) => {
          if (res.data.code === 200) {
            this.tableData = res.data.data.records
            this.totalCount = res.data.data.total
          } else {
            this.$message.error(res.data.message)
          }
        })
        .catch((err) => {
          this.$message.error(err)
        })
    },
    pagination(val) {
      this.searchModel.pageNo = val.page
      this.searchModel.pageSize = val.limit
      this.loadData()
    },
    // handleShow(row) {
    //   this.$refs.inBillDialog.show(row)
    // },
  },
}
</script>

<style lang="less" scoped>
.el-form-item {
  margin-bottom: 0 !important;
}
</style>
